package com.jtlrm.ckd.mvp.view.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jtlrm.ckd.R;
import com.jtlrm.ckd.base.acitvity.BaseActivity;
import com.jtlrm.ckd.base.acitvity.TitleBarActivity;
import com.jtlrm.ckd.mvp.view.adapter.NewsAdapter;
import com.jtlrm.ckd.mvp.view.adapter.PictureBottomAdapter;
import com.jtlrm.ckd.mvp.view.adapter.PictureTopAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class YinShiTuPianActivity extends BaseActivity {

    @BindView(R.id.list_top)
    RecyclerView topView;
    @BindView(R.id.list_bottom)
    RecyclerView bottomView;
    PictureTopAdapter topAdapter;
    PictureBottomAdapter bottomAdapter;
    ArrayList<String> pics;
    public static void showTuPian(Context context,ArrayList<String> pics){
        Intent intent = new Intent(context, YinShiTuPianActivity.class);
        intent.putStringArrayListExtra("tupian", pics);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        pics = getIntent().getStringArrayListExtra("tupian");
        super.onCreate(savedInstanceState);
    }


    @Override
    protected void setContentLayout() {
        setContentView(R.layout.activity_yin_shi_tu_pian);

    }

    @Override
    protected void initView() {
        if (pics == null || pics.size() == 0){
            return;
        }
        //设置布局管理器
        LinearLayoutManager topLayoutManager = new LinearLayoutManager(this);
        topLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        LinearLayoutManager bottomLayoutManager = new LinearLayoutManager(this);
        bottomLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        topAdapter = new PictureTopAdapter();
        topView.setLayoutManager(topLayoutManager);
        topView.setAdapter(topAdapter);
        bottomAdapter = new PictureBottomAdapter();
        bottomView.setLayoutManager(bottomLayoutManager);
        bottomView.setAdapter(bottomAdapter);
        topAdapter.addData(pics);
        bottomAdapter.addData(pics);

        topAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                bottomView.scrollToPosition(position);
            }
        });
        bottomAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                topView.scrollToPosition(position);
            }
        });

    }

    @Override
    protected void obtainData() {

    }

    @Override
    protected void initEvent() {

    }


    public void goBack(View view) {
        finish();
    }
}
